﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace KnockoutPaging.Controllers.api
{
    public class Data
    {
        public IList<int> rows { get; set; }
        public int totalRows { get; set; }
    }

    public class DataController : ApiController
    {

        // GET api/<controller>
        public IEnumerable<int> Get()
        {

            return null;
        }

        // GET api/<controller>/5

        [HttpGet]
        [ActionName("All")]
        public Data Get(int index, int size)
        {
            var data = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
            var rows = data.Skip(index* size).Take(size);
            return new Data()
                       {
                           rows = rows.ToList(),
                           totalRows = data.Count()

                       };

        }

        // POST api/<controller>
        public void Post([FromBody]string value)
        {
        }

        // PUT api/<controller>/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
        }
    }
}